(ns pe.p30
  (:use clojure.contrib.math)
  (:use pe.digits))


(defn power-of-digits-sum [n pow]
  (reduce + (map #(expt % pow) (digits n))))

(def search-limit (power-of-digits-sum 9999999 5))

(println (reduce + (filter #(= % (power-of-digits-sum % 5)) (range 2 search-limit))))